import 'package:flutter/material.dart';

class HomeList extends StatelessWidget {
  HomeList({super.key});
  List notifyList = [
    {
      'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
      'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
      'createdAt': '2024-09-22 15:00:00',
    },
    {
      'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
      'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
      'createdAt': '2024-09-22 15:00:00',
    },
    {
      'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
      'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
      'createdAt': '2024-09-22 15:00:00',
    },
  ];
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 10),
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              Image.asset('assets/images/notice@2x.png', width: 25),
              Text('社区', style: TextStyle(fontSize: 18, color: Colors.black)),
              Text(
                '公告',
                style: TextStyle(fontSize: 18, color: Colors.amberAccent),
              ),
            ],
          ),
          ListView(
            shrinkWrap: true, // 解决高度问题
            physics: NeverScrollableScrollPhysics(), // 禁止滚动
            children:
                notifyList.map((item) {
                  return GestureDetector(
                    onTap: () {
                      print(item['title']);
                    },
                    child: Container(
                      margin: const EdgeInsets.only(top: 10),
                      padding: const EdgeInsets.all(10),
                      decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(10),
                      ),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            item['title'],
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: const TextStyle(
                              color: Colors.black,
                              fontSize: 14,
                              fontWeight: FontWeight.bold,
                            ),
                          ),
                          const Divider(height: 8, color: Colors.transparent),
                          Text(
                            item['content'],
                            maxLines: 3,
                            overflow: TextOverflow.ellipsis,
                            style: const TextStyle(color: Colors.black),
                          ),
                          const Divider(height: 12, color: Colors.transparent),
                          Text(
                            item['createdAt'],
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: const TextStyle(color: Colors.grey),
                          ),
                        ],
                      ),
                    ),
                  );
                }).toList(),
          ),
        ],
      ),
    );
  }
}
